<?php
    namespace Npfe\Controller;
    use Think\Controller;
    class QcController  extends Controller{
        function Index(){
            $this->display();
        }
        function AddNewrow($mode = ''){
            $this->assign('getleibie',$this->getleibie());
            $this->assign('getpjleibie',$this->getpjleibie());
            switch($mode){
                case '1':
                    $this->display('qcmode1');
                    break;

                case '2':
                    $this->display('qcmode2');
                    break;
            }
        }
        function SubmitQcxq(){
            $qcxq = new \Npfe\Model\QcxqModel();

            $now_em = session('nickname');
            $appraise='';
            $groupname='';
            $headman='';
            $hwyname='';


            $isop = I('post.isop')==1?'是':'否';
            $isplan = I('post.isplan')==2?'是':'否';
            $isrepay = I('post.isrepay')==3?'是':'否';
            $iscommunicate = I('post.iscommunicate')==4?'是':'否';

            if(I('post.groupname')!=NULL){$groupname=I('post.groupname');};
            if(I('post.headman')!=NULL){$headman=I('post.headman');};
            if(I('post.hwyname')!=NULL){$hwyname=I('post.hwyname');};
            $appraise='总评：'.I('post.fa').'建议：'.I('post.fb');
            $data=array(
                'checknumber'=>  I('post.checknumber'),
                'sn'=>   I('post.sn'),
                'hwyid'=> I('post.hwyid'),
                'hwyname'=> I('post.hwyname'),
                'groupname'=> I('post.groupname'),
                'headman'=> I('post.headman'),
                'type'=> I('post.qclb'),
                'baseappraise'=> I('post.qcpjlb'),
                'link'=> $_POST['link'],
                'isop'=> $isop,
                'isplan'=> $isplan,
                'isrepay'=> $isrepay,
                'iscommunicate'=> $iscommunicate,
                'appraise'=> $appraise,
                'cltime'=> date('Y-m-d H:m:s'),
                'optext'=>I('post.optext'),
                'plantext'=> I('post.plantext'),
                'repaytext'=> I('post.repaytext'),
                'communicatetext'=> I('post.communicatetext'),
                'clname'=> $now_em
            );
            $res = $qcxq->add($data);

            if($res>0)
            {
                echo "<script>alert('操作成功!');</script>";
            }else{
                echo "<script>alert('操作不成功!');</script>";
            }
        }
        function SubmitQcxq2(){
            //新增一条新的质检记录在qcxq2的表里
            $qcxq2 = new \Npfe\Model\Qcxq2Model();

        }
        function getleibie(){
            $qc = new \Npfe\Model\QclbModel();
            $data = $qc->select();
            $showplist='<option value="请选择...">请选择...</option>';
            foreach($data as $row){
                $showplist.='<option value="'.$row['lbmc'].'">'.$row['lbmc'].'</option>';
            }
            return $showplist;
        }
        function getpjleibie(){
            $qc = new \Npfe\Model\QclbModel();
            $data = $qc->select();
            $showplist='<option value="请选择...">请选择...</option>';
            foreach($data as $row){
                if ($row['pjlbmc']!='') {
                    $showplist.='<option value="'.$row['pjlbmc'].'">'.$row['pjlbmc'].'</option>'; 
                }
            }
            return $showplist;
        }
    }
?>
